package com.zq.assistant.ui.test;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;
import android.widget.Toast;

import com.zq.assistant.R;
import com.zq.assistant.func.ioc.InjectUtils;
import com.zq.assistant.func.ioc.annotations.InjectView;
import com.zq.assistant.func.ioc.annotations.InjectListener;
import com.zq.assistant.func.ioc.listener.Listener;
import com.zq.assistant.ui.BaseActivity;

/**
 * Created by zhangqiang on 17-7-7.
 */

public class InjectorTestActivity extends BaseActivity {

    @InjectView(id = R.id.textView2)
    private TextView textView2;

    @InjectView(id = R.id.button)
    Button button2;

    @InjectView(id = R.id.checkBox)
    private CheckBox checkBox;

    public static void start(Context context) {

        Intent intent = new Intent(context, InjectorTestActivity.class);
        context.startActivity(intent);
    }


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_injector);

        long startTime = System.currentTimeMillis();
        InjectUtils.inject(this);
        Log.i("Test","总耗时 ： " + (System.currentTimeMillis() - startTime));
        textView2.setText("成功了");

//        button2.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//
//            }
//        });

        checkBox.setChecked(true);
    }

    @InjectListener(listener = Listener.OnClick,viewIds = R.id.button)
    public void onButtonClick(View view){
        Toast.makeText(InjectorTestActivity.this, "我也成功了", Toast.LENGTH_SHORT).show();
    }
}
